'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {
  //event为客户端上传的参数
  const collection = db.collection('products');
  let page=event.page-1;
  let skip_count=page*event.page_size
  let classify=event.classify;
  let posts;
  if(classify=="#"){
	  posts=await collection.skip(skip_count).orderBy("time", "desc").get()
  }else{
	  posts=await collection.where({"classify":event.classify}).skip(skip_count).orderBy("time", "desc").get()
  }
  // let posts=await collection.where({"classify":event.classify}).skip(skip_count)
  //let posts=await collection.where({"classify":event.classify}).skip(skip_count).orderBy("time", "desc").get()
  //返回数据给客户端

  return {"status":2, "lists":posts.data}
};